package cn.edu.wynu.apis.common;

public class CommonFunctions {
    public static void cutBlock(String s) {
        System.out.println("------------------" + s + "------------------");
    }

    public static void cutBlock() {
        System.out.println("--".repeat(20));
    }

    /**
     * 计算任务执行耗时
     * @param taskName 任务名称
     * @param task 任务
     * @return 任务执行耗时(毫秒)
     */
    public static long timeCost(String taskName, Runnable task) {
        long start = System.currentTimeMillis();
        task.run();
        long cost = System.currentTimeMillis() - start;
        System.out.printf("[%s] 执行耗时: %dms\n", taskName, cost);
        return cost;
    }
}
